package com.candy.header;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//@WebServlet(name = "servlet1")
public class servlet1 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //没有响应 告知客户端去重定向到servlet2
        //1、设置状态码302
        //response.setStatus(302);
        //2、设置响应头Location
        //response.setHeader("Location", "/web_heima_java0907/servlet2");

        //封装成一个重定向的方法sendRedirect(url)
        response.sendRedirect("/web_heima_java0907/servlet2");
    }
}
